package jenry.progessbar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;

public class Gan_ProgessBar extends Activity {
    /** Called when the activity is first created. */
	private ProgressBar firstBar = null;
	private ProgressBar secondBar = null;
	private Button myButton = null;
	private int i=0;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        firstBar = (ProgressBar)findViewById(R.id.firstBar);
        secondBar = (ProgressBar)findViewById(R.id.secondBar);
        myButton = (Button)findViewById(R.id.myButton);
        myButton.setOnClickListener(new myButtonListener());
    }
    
    class myButtonListener implements OnClickListener{

		public void onClick(View v) {
			if(i ==0){
				firstBar.setVisibility(View.VISIBLE);
				secondBar.setVisibility(View.VISIBLE);
			}
			else if (i< firstBar.getMax()){
				firstBar.setProgress(i);
				firstBar.setSecondaryProgress(i+10);
			}
			else{
				firstBar.setVisibility(View.GONE);
				secondBar.setVisibility(View.GONE);
			}
			i = i +10 ;
		}}
}